
import request from '@/router/axios'
export let Operator = {
  equal : "=",
  notEqual: "!=",
  leftLike: "left like",
  rightLike: "right like",
  like: "like",
  notLeftLike: "not left like",
  notRightLike: "not right like",
  notLike: "not like",
  greater: ">",
  greaterEqual: ">=",
  less:"<",
  lessEqual: "<=",
  between: "between",
  isNull: "is null",
  isNotNull: "is not null",
  in: "in",
  notIn: "not in"
}

export function queryData (dataTableId,query) {
  return request({
    url: '/datatable/data/page/' + dataTableId,
    method: 'post',
    data: query
    // {
    //   current: pageCurrent,
    //   size: pageSize,
    //   columns:columns,
    //   env: env,
    //   export: isExport,
    //   summary : isSummary,
    //   query:query
    // }
  })
}

export function addData (dataTableId,obj) {
  return request({
    url: '/datatable/data/create/' + dataTableId,
    method: 'post',
    data: obj
  })
}

export function deleteData (dataTableId,keyValues) {
  return request({
    url: '/datatable/data/delete/' + dataTableId,
    method: 'post',
    data: keyValues
  })
}

export function updateData (dataTableId,obj) {
  return request({
    url: '/datatable/data/update/' + dataTableId,
    method: 'post',
    data: obj
  })
}

export function queryDataTable (query) {
  return request({
    url: '/datatable/page',
    method: 'get',
    params: query
  })
}

export function createDataTableBySql (obj) {
  return request({
    url: '/datatable/createBySql',
    method: 'post',
    data: obj
  })
}

export function createDataTable (dataTableId,obj) {
  return request({
    url: '/datatable',
    method: 'post',
    data: obj
  })
}

export function copyDataTable (dataTableId,obj) {
  return request({
    url: '/datatable/copy/'+dataTableId,
    method: 'post',
    data: obj
  })
}

export function deleteDataTable (dataTableId) {
  return request({
    url: '/datatable/' + dataTableId,
    method: 'delete'
  })
}

export function updateDataTable (dataTableId,obj) {
  return request({
    url: '/datatable/' + dataTableId,
    method: 'put',
    data: obj
  })
}

export function getAVueOptionCode (dataTableId,pretty) {
  return request({
    url: '/datatable/avue/option/'+dataTableId,
    method: 'get',
    params: {
      pretty: pretty
    }
  })
}

export function getAVueIndexCode (dataTableId) {
  return request({
    url: '/datatable/avue/index/'+dataTableId,
    method: 'get'
  })
}

export function getMenuCode (dataTableId) {
  return request({
    url: '/datatable/menu/'+dataTableId,
    method: 'get'
  })
}

export function getDataTableCode (dataTableId) {
  return request({
    url: '/datatable/xml/'+dataTableId,
    method: 'get'
  })
}

export function downloadCode (dataTableId,obj) {
  return request({
    url: '/datatable/downloadCode/'+dataTableId,
    method: 'post',
    data: obj
  })
}
